import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    selectFoods: []
  },
  mutations: {
    setSelectFoods(state, val) {
      state.selectFoods = val
    },
    filterSelectFoods(state) {
      state.selectFoods = state.selectFoods.filter(item => item.count && item.count > 0)
    },
    emptyCart(state) {
      state.selectFoods.forEach(item => {
        item.count = 0
      })
      this.commit('filterSelectFoods')
    }
  },
  getters: {
  },
  actions: {}
})
